package com.ai.entity.security;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Objects;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;

/**
 * <p>
 * 用户表
 * </p>
 *
 * @author chen
 * @since 2023-04-04 19:46:07
 */
@Data
@TableName("sys_user")
@ApiModel(value = "SysUser对象", description = "用户表")
public class SysUser implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty("账号")
    @TableField("account")
    private String account;

    @ApiModelProperty("用户名")
    @TableField("user_name")
    private String userName;

    @ApiModelProperty("用户密码")
    @TableField("password")
    private String password;

    @ApiModelProperty("上一次登录时间")
    @TableField("last_login_time")
    private Date lastLoginTime;

    @ApiModelProperty("账号是否可用。默认为1（可用）")
    @TableField("enabled")
    private Boolean enabled;

    @ApiModelProperty("是否过期。默认为1（没有过期）")
    @TableField("not_expired")
    private Boolean notExpired;

    @ApiModelProperty("账号是否锁定。默认为1（没有锁定）")
    @TableField("account_not_locked")
    private Boolean accountNotLocked;

    @ApiModelProperty("证书（密码）是否过期。默认为1（没有过期）")
    @TableField("credentials_not_expired")
    private Boolean credentialsNotExpired;

    @ApiModelProperty("创建时间")
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private Date createTime;

    @ApiModelProperty("修改时间")
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    @ApiModelProperty("创建人")
    @TableField("create_user")
    private Integer createUser;

    @ApiModelProperty("修改人")
    @TableField("update_user")
    private Integer updateUser;

    @ApiModelProperty("当前用户所拥有的权限")
    @TableField(exist = false)
    private List<GrantedAuthority> grantedAuthorities;
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        SysUser sysUser = (SysUser) o;
        return Objects.equals(id, sysUser.id) && Objects.equals(account, sysUser.account) && Objects.equals(userName, sysUser.userName) && Objects.equals(password, sysUser.password) && Objects.equals(lastLoginTime, sysUser.lastLoginTime) && Objects.equals(enabled, sysUser.enabled) && Objects.equals(notExpired, sysUser.notExpired) && Objects.equals(accountNotLocked, sysUser.accountNotLocked) && Objects.equals(credentialsNotExpired, sysUser.credentialsNotExpired) && Objects.equals(createTime, sysUser.createTime) && Objects.equals(updateTime, sysUser.updateTime) && Objects.equals(createUser, sysUser.createUser) && Objects.equals(updateUser, sysUser.updateUser);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, account, userName, password, lastLoginTime, enabled, notExpired, accountNotLocked, credentialsNotExpired, createTime, updateTime, createUser, updateUser);
    }

    @Override
    public String toString() {
        return "SysUser{" +
                "id=" + id +
                ", account='" + account + '\'' +
                ", userName='" + userName + '\'' +
                ", password='" + password + '\'' +
                ", lastLoginTime=" + lastLoginTime +
                ", enabled=" + enabled +
                ", notExpired=" + notExpired +
                ", accountNotLocked=" + accountNotLocked +
                ", credentialsNotExpired=" + credentialsNotExpired +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", createUser=" + createUser +
                ", updateUser=" + updateUser +
                '}';
    }
}
